/**
 * Created by 游永年 on 2019-01-13 16:28.
 * 测试题题目,有听力题和测试题
 */

import {WhiteSpace, WingBlank, Card} from "antd-mobile";
import {connect} from 'dva';
import React, {Component} from 'react';
import style from './TestQuiz.less';

class Question extends Component {
  render() {
    const {content = '', questionType} = this.props;
    return (
      <div className={style.wrap}>
        <WhiteSpace/>
        <WingBlank>
          {questionType === '1' ?
            <audio src={content} controls="controls" className={style.audio}>
              您的浏览器不支持 audio 标签。
            </audio>
            : <Card full>
              <Card.Body>
                <div dangerouslySetInnerHTML={{__html: content}}/>
              </Card.Body>
            </Card>
          }
        </WingBlank>
      </div>
    );
  }
}

Question.propTypes = {};

const opts = ({quiz}) => {
  const {quizList = [], currIndex = 0} = quiz || {};
  //取当前题目
  const timu = quizList[currIndex] || {};
  const {content, questionType = '1'} = timu;
  return {
    content,
    questionType,//本题题型
  };
};

export default connect(opts)(Question);
